<template>
    <example :template-code="templateString">
        <template #describe>
            <t :id="`${$t('配置接口动态请求选项数据')}`">{{ $t('配置接口动态请求选项数据') }}</t>
            <li>
                通过<span class="s-code">requestConfig</span>接口请求配置对象，可实现自动请求并渲染下拉选项
            </li>
        </template>
        <div style="width: 300px;color:#666;">
            <sib-item v-model="value" :props="props"></sib-item>
        </div>
        <div style="color:#666;">
            <p>v-model 绑定值：{{ value }}</p>
        </div>
    </example>
</template>

<script>
import { ref, reactive } from 'vue';

export default {
    setup() {
        const value = ref([3, 65]);
        const props = reactive({
            type: 'cascader',
            optionProps: {
                label: 'name',
                value: 'id',
            },
            requestConfig: {
                url: '/api/tree-data.json',
                method: 'get',
                params: {},
            },
        });

        return {
            props,
            value,
            templateString: `<template>
    <sib-item v-model="value" :props="props"></sib-item>
    <p>v-model 绑定值：{{ value }}</p>
</template>

<script>
import { ref, reactive } from 'vue';

export default {
    setup() {
        const value = ref([3, 65]);
        const props = reactive({
            type: 'cascader',
            optionProps: {
                label: 'name',
                value: 'id',
            },
            requestConfig: {
                url: '/api/tree-data.json',
                method: 'get',
                params: {},
            },
        });

        return { props, value };
    },
};
<\/script>`,
        };
    },
};
</script>
